package offer.binarytree;


import java.util.Arrays;
import java.util.List;

/**
 * Description：
 * Author: zhangc
 * Date：2017/8/16 1:19
 */
public class TreeMirror19 {

    public static <T> void mirror(BinaryTree<T> root) {
        if (root == null)
            return;
        BinaryTree<T> temp = root.left;
        root.left = root.right;
        root.right = temp;
        mirror(root.left);
        mirror(root.right);
    }


    public static void main(String[] args) {
        BinaryTree<Integer> binaryTree = BinaryTree.createBinaryTree(Arrays.asList(8, 7, 0, 6, 0, 5, 0, 4));
        TreeMirror19.mirror(binaryTree);
        List<Integer> list = binaryTree.preOrder();
        for (Integer integer : list) {
            System.out.println(integer);
        }
    }
}
